// pages/shop/shop.js
import Toast from '@vant/weapp/toast/toast'
var data2 = require('../../utils/data.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        active:0,
        orderinfo:data2.getorderData(),
        display:false,
        foodlist:[]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      var that = this;
      // console.log(options);
      this.setData({
        shopId:options.shopId,
        shopName:options.shopName,
        shopPath:options.shopUrl,
        shopType:options.shopType
       });
       wx.request({
        url: 'http://localhost:8080/web/food/v1/findByShopId',
        data: {
            shopId: that.data.shopId
        }, //参数
        success: function (res) {
            that.setData({
                foodlist: res.data.data
            })
        },
        fail: function (err) {
            //失败执行
        }
    });


    },
    navgetDetall:function(e){
      // console.log(e.currentTarget.dataset);
        wx.navigateTo({
          url: '../details/details?foodId=' + e.currentTarget.dataset.id 
          + '&foodName=' + e.currentTarget.dataset.foodname 
          + '&foodUrl=' + e.currentTarget.dataset.urlpath 
          +'&foodPrice=' + e.currentTarget.dataset.foodprice 
          + '&foodDetail=' + e.currentTarget.dataset.fooddetail 
          + '&foodStaple=' + e.currentTarget.dataset.foodstaple,
        })
    },
      onClickButton() {
        wx.switchTab({
            url: '../order/order'
          })
      },
      onClickIcon(){
        var that = this;
        that.setData({
          display:!that.data.display,
        })
        wx.request({
          url: 'http://localhost:8080/orderCart/findAll',
          method: 'GET',
          success: res => {
            var price1 = 0;
            for (var i = 0; i < res.data.data.length; i++) {
              price1 += parseFloat(res.data.data[i].cuisinePrice)
            }
            console.log(price1)
            that.setData({
              paidList: res.data.data,
              price: price1 * 100
            })
          },
        });
      },
      openser(){
        wx.navigateTo({
          url: '../cusservice/cusservice',
        })
      }
})